package com.zlc.workflow.constant;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Objects;

@Getter
@AllArgsConstructor
public enum ProcessStatusEnum {


    DRAFT("DRAFT", "草稿"),
    PUBLISH("PUBLISH", "发布"),
    DEPRECATED("DEPRECATED", "废弃"),
    ;
    private String type;
    private String desc;

    public static ProcessStatusEnum getType(String type) {
        ProcessStatusEnum[] types = values();
        for (ProcessStatusEnum nodeType : types) {
            if (nodeType.type.equals(type)) {
                return nodeType;
            }
        }
        return null;
    }

    public static String getStatusName(String status) {
        ProcessStatusEnum statusEnum = getType(status);
        return Objects.nonNull(statusEnum) ? statusEnum.getDesc() : null;
    }
}
